﻿@model eBusiness.Models.News

@{
    ViewBag.Title = "Edit";
    Layout = "../Shared/_Layout.cshtml";
}
<script type="text/javascript">
    $(document).ready(function () {
        $('#ProductThumbImageUploader').change(function () {
            $("#tempThumbFile").html("");
            for (var i = 0; i < this.files.length; i++) {
                if (this.files && this.files[i]) {
                    var reader = new window.FileReader();
                    reader.onload = function (e) {
                        $("#tempThumbFile").append('<div style="float:left; max-width:120px; height:82px; overflow:hidden; margin-left:10px;"><img style="height:80px; border:solid 1px #80ABD5" src="' + e.target.result + '" alt="" /></div>');
                    };
                    reader.readAsDataURL(this.files[i]);
                }
            }
        });
        CKEDITOR.replace('ckeDetails',
        {
//            htmlEncodeOutput: true,
//            htmlEncodeInput: true,
            filebrowserBrowseUrl: '../../News/Edit'
        });
    });
</script>
<h2>
    Edit</h2>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Html.BeginForm("Edit", "News", FormMethod.Post, new { @enctype = "multipart/form-data" }))
{
    @Html.ValidationSummary(false)
    @Html.HiddenFor(model => model.ID)
    @Html.HiddenFor(model => model.CreatedBy)
    @Html.HiddenFor(model => model.CreatedDate)
    @Html.HiddenFor(model => model.ThumbImage)
    <fieldset>
        <legend>News</legend>
        <div class="editor-label">
            @Html.LabelFor(model => model.Title)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Title)
            @Html.ValidationMessageFor(model => model.Title,"*")
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.ThumbImage)
        </div>
        <div class="editor-field">
            <input type="file" id="ProductThumbImageUploader" name="file" style="width: 100%" />
            <div id="tempThumbFile" style="margin-top: 10px;">
                @if (!string.IsNullOrEmpty(Model.ThumbImage))
                {
                    <img style="height: 100px;" src="@Model.ThumbImage" alt="image"/>
                }
            </div>
            <div class="clearboth">
                <span></span>
            </div>
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Details)
        </div>
        <div class="editor-field">
            @Html.TextAreaFor(model => model.Details, new { @id = "ckeDetails" })            
            @Html.ValidationMessageFor(model => model.Details,"*")
        </div>
        <p>
            <input type="submit" value="Update" />
        </p>
    </fieldset>
}
<div>
    @Html.ActionLink("Back to List", "Index")
</div>
